package leetcode;

/**
 * 描述:55. 跳跃游戏
 *
 * @author Madison You
 * @created 22:21
 */
public class Mid_55_CanJump {
    public static void main(String[] args) {
        new Mid_55_CanJump().canJump(new int[]{2, 3, 1, 1, 4});
    }

    public boolean canJump(int[] nums) {
        if (nums.length == 1) {
            return true;
        }
        int cover = 0;
        for (int i = 0; i <= cover; i++) {
            cover = Math.max(nums[i] + i, cover);
            if (cover >= nums.length - 1) {
                return true;
            }
        }
        return false;
    }
}
